package com.apes.framework.plugin.esb.parser.element;

import com.apes.framework.plugin.esb.processor.ChainProcessor;
import com.apes.framework.plugin.esb.processor.router.FilterProcessor;
import com.apes.framework.plugin.filereader.xml.ApesElement;
import org.springframework.stereotype.Component;


/**
 * 功能：other元素解析器
 *
 * @author xul
 * @create 2018-04-16 14:25
 */
@Component
public class OtherElementParser extends AbstractNestedProcessorParser {

    /**
     * 可解析的元素列表
     **/
    private final String[] elementNames = {"other", "elseif"};

    /**
     * 功能：可解析的元素列表
     */
    @Override
    public String[] getNames() {
        return elementNames;
    }

    @Override
    public ChainProcessor parse(ApesElement element) {
        if (!element.getAttributes().containsKey("condition")) {
            element.getAttributes().put("condition", "1==1");
        }
        return super.parse(element);
    }

    @Override
    <T extends Class> T getChainProcessorClass() {
        return (T) FilterProcessor.class;
    }


}
